const Base = require('./base');

class Index extends Base
{
    async index() {
        // 首页列表
        const [list, pagination] = await this.$model.article.getIndexList(this.site.list_rows, true);
        // 友情链接
        const friend_links = await this.$model.link.getFriendLinks();
        // seo标题
        if (this.site.seo_title && this.site.webname) {
            this.$assign('title', this.site.seo_title + ' - ' + this.site.webname);
        } else if (this.site.seo_title) { 
            this.$assign('title', this.site.seo_title);
        }else if (this.site.webname) { 
            this.$assign('title', this.site.webname);
        }
        // console.log('list',pagination,(list && list.length && pagination))
        this.$assign('list', list);
        this.$assign('pagination', list && list.length && pagination ? pagination.render() : '');
        this.$assign('friend_links', friend_links);
        await this.$fetch();
    }
}

module.exports = Index;